package com.sophie.service.impl;

import com.sophie.DTO.CommentDTO;
import com.sophie.dao.ICommentDAO;
import com.sophie.dao.impl.CommentDAOImpl;
import com.sophie.entity.Comment;
import com.sophie.service.ICommentService;
import com.sophie.util.ResultVO;

import java.util.List;

/**
 * @Author: Rowena
 * @CreateTime: 2024-09-11 17:16:53
 * @Version: 1.0
 */

public class CommentServiceImpl implements ICommentService {
    ICommentDAO commentDAO = new CommentDAOImpl();
    @Override
    public ResultVO addComment(Comment comment) {
        int i = commentDAO.addComment(comment);
        if (i>0){
            return ResultVO.ok("评论成功!");
        }
        return ResultVO.fail("评论失败!");
    }

    @Override
    public ResultVO getCommentByZoneId(Integer id) {
        List<CommentDTO> list = commentDAO.getCommentByZoneId(id);
        return ResultVO.ok("评论获取成功!").setData(list);

    }

    @Override
    public ResultVO countCommentByZoneId(Integer id) {
        long l = commentDAO.countCommentByZoneId(id);
        return ResultVO.ok("成功计算评论数!").setData(l);
    }
}
